<?php 
/**
 * Copyright (c) 2010, Slawomir Mazur <mazursllawek@gmail.com>
 * 
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions 
 * are met:
 * 
 * o Redistributions of source code must retain the above copyright notice, 
 *   this list of conditions and the following disclaimer.
 * o Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation
 *   and/or other materials provided with the distribution.
 * o Neither the name of the Softisland nor the names of its contributors
 *   may be used to endorse or promote products derived from this software
 *   without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
/**
 * Enter description here...
 *
 * @package     Cms
 * @copyright   Slawomir Mazur (c) 2010 (http://www.zend.com/zce.php?c=ZEND011643)
 * @license     http://www.opensource.org/licenses/bsd-license.php
 * @author      Slawomir Mazur <mazursllawek@gmail.com>
 */
?>
<div class="container">
	<form id="searchForm" action="<?php echo $this->baseUrl('index/result') ?>" method="post">
		<div class="search-box">
			<div><?php echo $this->messenger(Gp_View_Helper_Messenger::FRONTEND_MESSENGER) ?></div>
			<label class="example"><strong>[</strong>eg. Gene Symbol: 
			<a href="<?php echo $this->baseUrl('index/result/q/BLOC1S2/a/6') ?>">BLOC1S2</a> 
			or siRNA Sequence: 
			<a href="<?php echo $this->baseUrl('index/result/q/CAGCUUGAAGUAUCUUGAAtt/a/2') ?>">CAGCUUGAAGUAUCUUGAAtt</a>
			(select Search by: Sequence)<strong>]</strong></label>
			<label class="example"><strong>[</strong>For batch query, please insert genes or sequences delimited by comma, semicolon, space or tabulator.
			<br />I.e.: <a href="<?php echo $this->baseUrl('index/result/q/APPL,BLOC1S2,RPS3/a/6') ?>">APPL, BLOC1S2, RPS3</a>. This allows to copy-paste genes or siRNAs from text tables<strong>]</strong></label>
			<div id="qbox" class="left">
				<input type="text" value="" name="q" id="q" />	
			</div>
			<div id="search" class="left"></div>
			
			<div class="search-attributes clear-left">
				<div>
					<label for="a"><?php echo $this->translate('Search by:') ?></label>
					<select name="a" id="a">
						<?php echo $this->attribute()->getSearchableAttributesAsHTML() ?>
					</select>
				</div>
				<div>
					<label for="y"><?php echo $this->translate('Annotation:') ?></label>
					<select name="y" id="y">
						<?php echo $this->library()->getAnnotationYearsAsHTML() ?>
					</select>
					<label id="about">?</label>
				</div>
				<div>
					<label><?php echo $this->translate('Select library attributes:') ?></label>
					<span title="Click to open" id="aetext">[...]</span>
					<div id="aeholder">
						<div id="aeclose"><span title="Close Attributes list">X</span></div>
						<div><?php echo $this->attribute()->getAttributesAsHTML() ?></div>
					</div>
					<label id="attributes">?</label>
				</div>
			</div>
		</div>
	</form>
</div>
<div id="note" class="tooltip-note">
Please select Genebank annotation year<br />
Eg. If you received your siRNAs in 2007, and design of siRNA has been based on annotation from year 2007 or earlier.<br />
In such case: <br />
If you select 2007 as a annotation year your annotation received from siRNA supplier should match to RNAiAtlas annotation.<br />
If you select latest annotation, you will receive information about current status of siRNA<br />annotation from latest transcriptome
and related information:<br />
If siRNA target currently<br />
 - pseudogene<br />
 - has been wrong predicted<br />
 - target different gene (information about off-target)<br />
Information about total number of target transcipts for selected siRNA 
</div>
<div id="attr-note" class="tooltip-note">
Please select library attributes that you're interested in during the search process. <br />
Leave this field blank <code>[...]</code> in case you're intereseted in all library attributes.
</div>
<script type="text/javascript">
//<![CDATA[
	$('#q').focus(function () { $(this).parent().addClass('hover'); });
	$('#q').blur(function () { $(this).parent().removeClass('hover'); });
	$('#search').hover(
		function () { $(this).addClass('hover'); },
		function () { $(this).removeClass('hover'); }
	);
	$('#search').click(function() {
		$('#searchForm').submit();
	});

	$('#q').focus();

	$('#about').hover(
		function (event) {
			nX = event.pageX;
			nY = event.pageY;
			
			$('#note').css({ top: nY + 10, left: nX + 10, display: 'block' });
		},
		function () {
			$('#note').css({ display : 'none' });
		}
	);

	var isOn = false;
	
	$('#aetext').click(function() {
		if (isOn) {
			createAttributesList();
		} else {
			$('#aeholder div').show(); 
			$('#aeholder div').css({ top: $('#aetext').height() + 35 });
			$('#aeholder div#aeclose').css({ top: $('#aetext').height() + 10 });
			isOn = true;
		}
	});

	$('#aeholder div label').hover(
		function() { $(this).css({ opacity: .6 }); },
		function() { $(this).css({ opacity: 1 }); }
	)
	
	$('#aeclose').click(createAttributesList);

	function createAttributesList() {
		$('#aeholder div').hide();
		isOn = false;

		var text = '';
		$('#aeholder div label input:checked').each(function() {
			text += $(this).parent().text() + ', ';
		});

		// check for text changes
		if ('' != text) {
			$('#aetext').text(text.substring(0, text.lastIndexOf(',')));
		} else {
			$('#aetext').text('[...]');
		}
	}
	
	$('#attributes').hover(
		function (event) {
			nX = event.pageX;
			nY = event.pageY;
			
			$('#attr-note').css({ top: nY + 10, left: nX + 10, display: 'block' });
		},
		function () {
			$('#attr-note').css({ display : 'none' });
		}
	);
//]]>
</script>